<template>
	<view class="page">
		<!-- #ifdef APP-PLUS -->
		<view class="status_bar">
			<!-- 这是状态栏 -->
		</view>
<uni-nav-bar left-icon="left" title="我的钱包" backgroundColor="#6A9FFB" color="#fff" @clickLeft="clickLeft" />
		<!-- #endif -->
		
		<view class="head">
			<view class="">
				<view class="">
					{{number.parsePrice(balance)}}
				</view>
				<view class="">
					账户余额
				</view>
			</view>
		</view>
		<view class="concente">
			<view class="with_card">
				<view class="card_list">
					<view style="font-size: 15px;">到账银行卡</view>
					<view style="font-size: 12px; " @click="show=true" class="diaply">
						<view>{{bankName}}</view>
						<image src="/static/img/ic_down_black.png" mode="widthFix"
							style="width: 10px;margin-left: 8px;"></image>
					</view>
				</view>

			</view>
			<view class="amount">提现金额</view>
			<view class="input_amount">
				<text>￥</text>
				<input type="text" name="amt" v-model="tixianForm.amt" />
			</view>
			<view class="font">当前可提现金额{{number.parsePrice(balance)}}元<text class="all_with" @click="allwith"
					style="margin-left:30rpx;">全部提现</text></view>
			<button class="loginbtn" @click="tixian">提交</button>
			<view class="size">
				<view class="">
					注意事项:
				</view>
				<view class="">
					1、最低提现金额<text class="rule">{{config.minAmt}}元</text>
				</view>
				<view class="">
					2、收取<text class="rule">{{config.fee}}元</text>/笔手续费
				</view>
				<view class="">
					3、日结算5万以下，提交后D+1到账，日结算5万以上，提交后D1到~D2到账，遇节假日顺延。
				</view>
			</view>
		</view>
		<!-- <u-picker mode="selector" v-model="show" :range="selector"></u-picker> -->
		<u-select v-model="show" :list="selector" @confirm="confirm"></u-select>
	</view>
</template>

<script>
	const api = require('../../config/api');
	const util = require('../../utils/util');
	import number from '../../utils/number.js'
	export default {
		data() {
			return {
				number: number, //声明number属性并赋值为引入的number模块
				balance: '0.00',
				settlementId: '',
				config: {},
				selector: [],
				show: false,
				bankName: '',
				tixianForm: {
					"amt": 0,
					"settlementId": 0
				}

			}
		},
		onLoad() {

		},
		onShow() {
			this.getaccountBalance();
			this.getsettlementList();
		},
		methods: {
			clickLeft(){uni.navigateBack()},
			allwith(){
				this.tixianForm.amt = this.balance
			},
			tixian() {
				if (this.tixianForm.amt < this.config.minAmt) {
					uni.showToast({
						title: '请输入正确的提现金额',
						icon: 'none'
					})
					return;
				}
				this.tixianConfirm();
			},
			async tixianConfirm() {
				const res = await util.request(
					api.tixianUrl, {
			...this.tixianForm
					},
					'POST'
				)
				// console.log(res);
				if (res.code !== 0) {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
				} else {
					uni.showToast({
						title: "提交成功",
						icon: 'none'
					})
					this.tixianForm.amt = 0
					this.getaccountBalance();
				}
			},
			confirm(e) {
				// console.log(e);
				this.tixianForm.settlementId = e[0].value
			},
			// 
			async getaccountBalance() {
				const res = await util.request(
					api.accountBalanceUrl, {

					},
					'POST'
				)
				// console.log(res);
				if (res.code !== 0) {} else {
					this.balance = res.data.balance
					this.config = res.data.tixianConfig
				}
			},
			async getsettlementList() {
				const res = await util.request(
					api.settlementListUrl, {

					},
					'POST'
				)
				// console.log(res);
				if (res.code !== 0) {} else {
					// settlementList
					this.settlementList = res.data
					this.selector = res.data.map(item => ({
						value: item.id,
						label: JSON.parse(item.cardInfo).bankName + JSON.parse(item.cardInfo).accNo.slice(-
							4)

					}));
					this.bankName = JSON.parse(res.data[0].cardInfo).bankName + JSON.parse(res.data[0].cardInfo).accNo
						.slice(-
							4)
						this.tixianForm.settlementId = res.data[0].id

				}
			},
		}
	}
</script>
<style>
	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
		background-color: #6A9FFB;
	}

	.uni-navbar--border {
		border-bottom-style: none !important;
	}
</style>
<style lang="scss" scoped>
	// .page {
	// 	padding: 20rpx 32rpx;
	// }

	.with_card {
		// margin: 10px 15px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #6A9FFB;
		border-radius: 5px;
		padding: 10px 0px;
	}

	.with_card>view {
		background-color: #6A9FFB;
		width: 100%;
		// height: 140rpx;
		color: white;
		font-size: 30rpx;
		border-radius: 10rpx;
		text-align: center;
		color: #fff;
	}

	.card_list>view:first-child {
		margin-top: 20rpx;
	}

	.amount {
		font-size: 15px;
		margin: 10px 0;
	}

	.input_amount {
		display: flex;
		align-items: center;
		padding: 10rpx 0;
		border-bottom: 1rpx solid #eee;
	}

	.input_amount>text {
		font-size: 25px;
	}

	.input_amount>input {

		margin-left: 10rpx;
		width: 100%;
		font-size: 40rpx;
	}

	.font {
		margin-top: 10rpx;
		font-size: 14px;
	}

	.all_with {
		color: #93B9FC;
	}

	.rule {

		color: #E2556B;
	}

	.loginbtn {
		margin: 20px;
		background-color: #6A9FFB;
		height: 45px;
		line-height: 45px;
		text-align: center;
		color: #fff;
		font-weight: 300;
		font-size: 16px;
		border-radius: 15px;
	}

	.size {
		font-size: 13px;
		color: #666;
		text-align: left;
		// text-align: center;
	}

	.head {
		// padding: 50rpx 0 150rpx 32rpx;
		// background-image: linear-gradient(to right,#FF435A,#BA1031);
		background-color: #6A9FFB;
		height: 220rpx;
		color: white;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.concente {
		padding: 20rpx 32rpx;
	}

	.diaply {
		margin-top: 5px;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>